(function(){function e(e,t,i){this.editor=e;this.element=t;this.container=i;this.config=e.config||{};this.isShown=null;this.bbCode=e.bbCode;BX.addCustomEvent(this.editor,"OnClickBefore",BX.proxy(this.OnClick,this))}e.prototype={Focus:function(){if(!document.querySelector||this.element.ownerDocument.querySelector(":focus")===this.element)return;try{this.element.focus()}catch(e){}},Hide:function(){this.isShown=false;this.container.style.display="none"},Show:function(){this.isShown=true;this.container.style.display=""},Disable:function(){this.element.setAttribute("disabled","disabled")},Enable:function(){this.element.removeAttribute("disabled")},OnClick:function(e){},IsShown:function(){return!!this.isShown}};function t(e,t,o){i.superclass.constructor.apply(this,arguments);this.name="textarea";this.InitEventHandlers();if(!this.element.value&&this.editor.config.content)this.SetValue(this.editor.config.content,false)}BX.extend(t,e);t.prototype.Clear=function(){this.element.value=""};t.prototype.GetValue=function(e){var t=this.IsEmpty()?"":this.element.value;if(e){t=this.parent.parse(t)}return t};t.prototype.SetValue=function(e,t,i){if(t){e=this.editor.Parse(e,true,i)}this.editor.dom.pValueInput.value=this.element.value=e};t.prototype.SaveValue=function(){if(this.editor.inited){this.editor.dom.pValueInput.value=this.element.value}};t.prototype.HasPlaceholderSet=function(){var e=this.element.getAttribute("placeholder")||null,t=this.element.value;return!t||t===e};t.prototype.IsEmpty=function(){var e=BX.util.trim(this.element.value);return e===""||this.HasPlaceholderSet()};t.prototype.InitEventHandlers=function(){var e=this;BX.bind(this.element,"focus",(function(){e.editor.On("OnTextareaFocus");e.isFocused=true}));BX.bind(this.element,"blur",(function(){e.editor.On("OnTextareaBlur");e.isFocused=false}));BX.bind(this.element,"keydown",(function(t){e.editor.textareaKeyDownPreventDefault=false;if((t.ctrlKey||t.metaKey)&&!t.altKey&&t.keyCode===e.editor.KEY_CODES["enter"]){e.editor.On("OnCtrlEnter",[t,e.editor.GetViewMode()]);return BX.PreventDefault(t)}e.editor.On("OnTextareaKeydown",[t]);if(e.editor.textareaKeyDownPreventDefault)return BX.PreventDefault(t)}));BX.bind(this.element,"keyup",(function(t){e.editor.On("OnTextareaKeyup",[t])}))};t.prototype.IsFocused=function(){return this.isFocused};t.prototype.ScrollToSelectedText=function(e){};t.prototype.SelectText=function(e){var t=this.element.value,i=t.indexOf(e);if(i!=-1){this.element.focus();this.element.setSelectionRange(i,i+e.length)}};t.prototype.GetTextSelection=function(){var e=false;if(this.element.selectionStart!=undefined){e=this.element.value.substr(this.element.selectionStart,this.element.selectionEnd-this.element.selectionStart)}else if(document.selection&&document.selection.createRange){e=document.selection.createRange().text}else if(window.getSelection){e=window.getSelection();e=e.toString()}return e};t.prototype.WrapWith=function(e,t,i){if(!e)e="";if(!t)t="";if(!i)i="";if(e.length<=0&&t.length<=0&&i.length<=0)return true;var o=!!i,n=this.GetTextSelection(),r=n?"select":o?"after":"in";if(o){i=e+i+t}else if(n){i=e+n+t}else{i=e+t}if(this.element.selectionStart!=undefined){var s=this.element.scrollTop,a=this.element.selectionStart,l=this.element.selectionEnd;this.element.value=this.element.value.substr(0,a)+i+this.element.value.substr(l);if(r=="select"){this.element.selectionStart=a;this.element.selectionEnd=a+i.length}else if(r=="in"){this.element.selectionStart=this.element.selectionEnd=a+e.length}else{this.element.selectionStart=this.element.selectionEnd=a+i.length}this.element.scrollTop=s}else if(document.selection&&document.selection.createRange){var d=document.selection.createRange();var u=d.duplicate();i=i.replace(/\r?\n/g,"\n");d.text=i;d.setEndPoint("StartToStart",u);d.setEndPoint("EndToEnd",u);if(r=="select"){d.collapse(true);i=i.replace(/\r\n/g,"1");d.moveEnd("character",i.length)}else if(r=="in"){d.collapse(false);d.moveEnd("character",e.length);d.collapse(false)}else{d.collapse(false);d.moveEnd("character",i.length);d.collapse(false)}d.select()}else{this.element.value+=i}return true};t.prototype.GetCursorPosition=function(){return this.element.selectionStart};function i(e,t,o){i.superclass.constructor.apply(this,arguments);this.name="wysiwyg";this.caretNode="<br>"}BX.extend(i,e);i.prototype.OnCreateIframe=function(){this.document=this.editor.sandbox.GetDocument();this.element=this.document.body;this.editor.document=this.document;this.textarea=this.editor.dom.textarea;this.isFocused=false;this.InitEventHandlers();window.rangy.init();this.Enable()};i.prototype.Clear=function(){this.element.innerHTML=this.caretNode};i.prototype.GetValue=function(e,t){this.iframeValue=this.IsEmpty()?"":this.editor.GetInnerHtml(this.element);this.editor.On("OnIframeBeforeGetValue",[this.iframeValue]);if(e){this.iframeValue=this.editor.Parse(this.iframeValue,false,t)}return this.iframeValue};i.prototype.SetValue=function(e,t){if(t){e=this.editor.Parse(e)}this.element.innerHTML=e;this.CheckContentLastChild(this.element);this.editor.On("OnIframeSetValue",[e])};i.prototype.Show=function(){this.isShown=true;this.container.style.display="";this.ReInit()};i.prototype.ReInit=function(){this.Disable();this.Enable();this.editor.On("OnIframeReInit")};i.prototype.Hide=function(){this.isShown=false;this.container.style.display="none"};i.prototype.Disable=function(){this.element.removeAttribute("contentEditable")};i.prototype.Enable=function(){this.element.setAttribute("contentEditable","true")};i.prototype.Focus=function(e){if(BX.browser.IsIE()&&this.HasPlaceholderSet()){this.Clear()}if(!document.querySelector||this.element.ownerDocument.querySelector(":focus")!==this.element||!this.IsFocused()){if(BX.browser.IsIOS()){var t=this;if(this.focusTimeout)clearTimeout(this.focusTimeout);this.focusTimeout=setTimeout((function(){var e=document.documentElement.scrollTop||document.body.scrollTop,i=document.documentElement.scrollLeft||document.body.scrollLeft;BX.focus(t.element);window.scrollTo(i,e)}),200)}else{BX.focus(this.element)}}if(e&&this.element.lastChild){if(this.element.lastChild.nodeName==="BR"){this.editor.selection.SetBefore(this.element.lastChild)}else{this.editor.selection.SetAfter(this.element.lastChild)}}};i.prototype.SetFocusedFlag=function(e){this.isFocused=e};i.prototype.IsFocused=function(){return this.isFocused};i.prototype.GetTextContent=function(e){var t=this.editor.util.GetTextContent(this.element);return e===true?t.replace(/\uFEFF/gi,""):t};i.prototype.HasPlaceholderSet=function(){return this.textarea&&this.GetTextContent()==this.textarea.getAttribute("placeholder")};i.prototype.IsEmpty=function(e){if(!document.querySelector)return false;var t=this.element.innerHTML,i="blockquote, ul, ol, img, embed, object, table, iframe, svg, video, audio, button, input, select, textarea";return t===""||t===this.caretNode||this.HasPlaceholderSet()||this.GetTextContent(e)===""&&!this.element.querySelector(i)};i.prototype._initObjectResizing=function(){var e=["width","height"],t=e.length,i=this.element;this.commands.exec("enableObjectResizing",this.config.allowObjectResizing);if(this.config.allowObjectResizing){if(browser.supportsEvent("resizeend")){dom.observe(i,"resizeend",(function(o){var n=o.target||o.srcElement,r=n.style,s=0,a;for(;s<t;s++){a=e[s];if(r[a]){n.setAttribute(a,parseInt(r[a],10));r[a]=""}}redraw(i)}))}}else{if(browser.supportsEvent("resizestart")){dom.observe(i,"resizestart",(function(e){e.preventDefault()}))}}};var o=function(e){if(e.setActive){try{e.setActive()}catch(e){}}else{var t=e.style,i=doc.documentElement.scrollTop||doc.body.scrollTop,o=doc.documentElement.scrollLeft||doc.body.scrollLeft,n={position:t.position,top:t.top,left:t.left,WebkitUserSelect:t.WebkitUserSelect};dom.setStyles({position:"absolute",top:"-99999px",left:"-99999px",WebkitUserSelect:"none"}).on(e);e.focus();dom.setStyles(n).on(e);if(win.scrollTo){win.scrollTo(o,i)}}};i.prototype.InitEventHandlers=function(){var e=this,t=this.editor,i=this.GetValue(),o=this.element,n=this.editor.sandbox.GetWindow(),r=!BX.browser.IsOpera()?o:this.editor.sandbox.GetWindow();if(this._eventsInitedObject&&this._eventsInitedObject===r)return;this._eventsInitedObject=r;BX.bind(r,"focus",(function(){t.On("OnIframeFocus");e.isFocused=true;if(i!==e.GetValue())BX.onCustomEvent(t,"OnIframeChange")}));BX.bind(r,"blur",(function(){t.On("OnIframeBlur");e.isFocused=false;setTimeout((function(){i=e.GetValue()}),0)}));BX.bind(r,"contextmenu",(function(i){if(i&&!i.ctrlKey&&!i.shiftKey&&BX.getEventButton(i)&BX.MSRIGHT){t.On("OnIframeContextMenu",[i,i.target||i.srcElement,e.contMenuRangeCollapsed])}}));BX.bind(r,"mousedown",(function(i){var o=t.selection.GetRange(),n=i.target||i.srcElement,r=t.GetBxTag(n);e.contMenuRangeCollapsed=o&&o.collapsed;if(t.synchro.IsSyncOn()){t.synchro.StopSync()}if(BX.browser.IsIE10()||BX.browser.IsIE11()){t.phpParser.RedrawSurrogates()}if(n.nodeName=="BODY"||!t.phpParser.CheckParentSurrogate(n)){setTimeout((function(){o=t.selection.GetRange();if(o&&o.collapsed&&o.startContainer&&o.startContainer==o.endContainer){var e=t.phpParser.CheckParentSurrogate(o.startContainer);if(e){t.selection.SetInvisibleTextAfterNode(e);t.selection.SetInvisibleTextBeforeNode(e)}}}),10)}t.action.actions.quote.checkSpaceAfterQuotes(n);t.selection.SaveRange(false);setTimeout((function(){t.selection.SaveRange(false)}),10);t.On("OnIframeMouseDown",[i,n,r])}));BX.bind(r,"touchend",(function(){e.Focus()}));BX.bind(r,"touchstart",(function(){e.Focus()}));BX.bind(r,"click",(function(e){var i=e.target||e.srcElement;t.On("OnIframeClick",[e,i])}));BX.bind(r,"dblclick",(function(e){var i=e.target||e.srcElement;t.On("OnIframeDblClick",[e,i])}));BX.bind(r,"mouseup",(function(e){var i=e.target||e.srcElement;if(!t.synchro.IsSyncOn()){t.synchro.StartSync()}t.On("OnIframeMouseUp",[e,i])}));BX.bind(o,"dragover",(function(){t.On("OnIframeDragOver",arguments)}));BX.bind(o,"dragenter",(function(){t.On("OnIframeDragEnter",arguments)}));BX.bind(o,"dragleave",(function(){t.On("OnIframeDragLeave",arguments)}));BX.bind(o,"dragexit",(function(){t.On("OnIframeDragExit",arguments)}));BX.bind(o,"drop",(function(){t.On("OnIframeDrop",arguments)}));if(BX.browser.IsFirefox()){BX.bind(o,"dragover",(function(e){e.preventDefault()}));BX.bind(o,"dragenter",(function(e){e.preventDefault()}))}BX.bind(o,"drop",BX.delegate(this.OnPasteHandler,this));BX.bind(o,"paste",BX.delegate(this.OnPasteHandler,this));BX.bind(o,"keyup",(function(i){var o=i.keyCode,n=t.selection.GetSelectedNode(true);e.SetFocusedFlag(true);if(o===t.KEY_CODES["space"]||o===t.KEY_CODES["enter"]){if(o===t.KEY_CODES["enter"]){e.OnEnterHandlerKeyUp(i,o,n)}t.On("OnIframeNewWord")}else{e.OnKeyUpArrowsHandler(i,o)}t.selection.SaveRange();t.On("OnIframeKeyup",[i,o,n]);if(o===t.KEY_CODES["backspace"]&&BX.browser.IsChrome()&&n&&n.nodeType=="3"&&n.nextSibling&&n.nextSibling.nodeType=="3"){e.editor.selection.ExecuteAndRestoreSimple((function(){e.editor.util.SetTextContent(n,e.editor.util.GetTextContent(n)+e.editor.util.GetTextContent(n.nextSibling));n.nextSibling.parentNode.removeChild(n.nextSibling)}))}if(!t.util.FirstLetterSupported()&&e.editor.parser.firstNodeCheck){e.editor.parser.FirstLetterCheckNodes("","",true)}if(BX.browser.IsChrome()){if(e.stopBugusScrollTimeout)clearTimeout(e.stopBugusScrollTimeout);e.stopBugusScrollTimeout=setTimeout((function(){e.stopBugusScroll=false}),200)}}));BX.bind(o,"mousedown",(function(i){var o=i.target||i.srcElement;if(!t.util.CheckImageSelectSupport()&&o.nodeName==="IMG"){t.selection.SelectNode(o)}if(!t.util.CheckPreCursorSupport()&&o.nodeName==="PRE"){var n=t.selection.GetSelectedNode(true);if(n&&n!=o){e.FocusPreElement(o,true)}}}));BX.bind(o,"keydown",BX.proxy(this.KeyDown,this));if(BX.browser.IsChrome()){BX.bind(window,"scroll",BX.proxy((function(t){if(e.stopBugusScroll){if((!e.savedScroll||!e.savedScroll.scrollTop)&&e.lastSavedScroll)e.savedScroll=e.lastSavedScroll;if(e.savedScroll&&!e.lastSavedScroll)e.lastSavedScroll=e.savedScroll;e._RestoreScrollTop()}}),this))}var s={IMG:BX.message.SrcTitle+": ",A:BX.message.UrlTitle+": "};BX.bind(o,"mouseover",(function(e){var t=e.target||e.srcElement,i=t.getAttribute("href")||t.getAttribute("src"),o=t.nodeName;if(s[o]&&!t.hasAttribute("title")&&i&&i.indexOf("data:image/")===-1){t.setAttribute("title",s[o]+i);t.setAttribute("data-bx-clean-attribute","title")}}));this.editor.InitClipboardHandler()};i.prototype.KeyDown=function(e){var t=this,i=e.keyCode,o=this.editor.KEY_CODES;this.SetFocusedFlag(true);this.editor.iframeKeyDownPreventDefault=false;if(BX.browser.IsChrome()){this.stopBugusScroll=true;this.savedScroll=BX.GetWindowScrollPos(document)}var n=this.editor.SHORTCUTS[i],r=this.editor.selection.GetSelectedNode(true),s=this.editor.selection.GetRange(),a=this.document.body,l;if((BX.browser.IsIE()||BX.browser.IsIE10()||BX.browser.IsIE11())&&!BX.util.in_array(i,[16,17,18,20,65,144,37,38,39,40])){if(r&&r.nodeName=="BODY"||s.startContainer&&s.startContainer.nodeName=="BODY"||s.startContainer==a.firstChild&&s.endContainer==a.lastChild&&s.startOffset==0&&s.endOffset==a.lastChild.length){BX.addCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._IEBodyClearHandler,this))}}if((BX.browser.IsIE()||BX.browser.IsIE10()||BX.browser.IsIE11())&&i==o["backspace"]){BX.addCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._IEBodyClearHandlerEx,this))}this.isUserTyping=true;if(this.typingTimeout){this.typingTimeout=clearTimeout(this.typingTimeout)}this.typingTimeout=setTimeout((function(){t.isUserTyping=false}),1e3);this.editor.synchro.StartSync(200);this.editor.On("OnIframeKeydown",[e,i,n,r]);if(this.editor.iframeKeyDownPreventDefault)return BX.PreventDefault(e);if((e.ctrlKey||e.metaKey)&&!e.altKey&&n){this.editor.action.Exec(n);return BX.PreventDefault(e)}if(i===o["backspace"]&&s.startOffset==0&&s.startContainer.nodeType==3&&s.startContainer.parentNode.firstChild==s.startContainer&&s.startContainer.parentNode&&s.startContainer.parentNode.nodeName=="BLOCKQUOTE"&&s.startContainer.parentNode.className){s.startContainer.parentNode.className=""}if(i===o["delete"]&&s.collapsed&&s.endContainer.nodeType==3&&s.endOffset==s.endContainer.length){var d=this.editor.util.GetNextNotEmptySibling(s.endContainer);if(d){if(d.nodeName=="BR"){d=this.editor.util.GetNextNotEmptySibling(d)}if(d&&d.nodeName=="BLOCKQUOTE"&&d.className){d.className=""}}}if(r&&r.nodeName==="IMG"&&(i===o["backspace"]||i===o["delete"])){l=r.parentNode;l.removeChild(r);if(l.nodeName==="A"&&!l.firstChild){l.parentNode.removeChild(l)}setTimeout((function(){t.editor.util.Refresh(t.element)}),0);BX.PreventDefault(e)}if(s.collapsed&&this.OnKeyDownArrowsHandler(e,i,s)===false){return false}if((e.ctrlKey||e.metaKey)&&!e.altKey&&i===o["enter"]){if(this.IsFocused())this.editor.On("OnIframeBlur");this.editor.On("OnCtrlEnter",[e,this.editor.GetViewMode()]);return BX.PreventDefault(e)}if(BX.browser.IsFirefox()&&r&&(i===o["delete"]||i===o["backspace"])){var u=r.nodeName=="LI"?r:BX.findParent(r,{tag:"LI"},a);if(u&&u.firstChild&&u.firstChild.nodeName=="I"){var c=BX.findParent(u,{tag:"UL"},a);if(c){var f=this.editor.action.actions.insertUnorderedList.getCustomBullitClass(c);if(f){setTimeout((function(){if(c&&u&&u.innerHTML!==""){t.editor.action.actions.insertUnorderedList.checkCustomBullitList(c,f)}}),0)}}}}if(!this.editor.util.FirstLetterSupported()&&t.editor.parser.firstNodeCheck&&i===this.editor.KEY_CODES["backspace"]){t.editor.parser.FirstLetterBackspaceHandler(s)}if(!e.shiftKey&&(i===o["enter"]||i===o["backspace"])){return this.OnEnterHandler(e,i,r,s)}if(i===o["pageUp"]||i===o["pageDown"]){this.savedScroll=BX.GetWindowScrollPos(document);BX.addCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._RestoreScrollTop,this));setTimeout(BX.proxy(this._RestoreScrollTop,this),0)}};i.prototype._RestoreScrollTop=function(e){if(this.savedScroll){window.scrollTo(this.savedScroll.scrollLeft,this.savedScroll.scrollTop);this.savedScroll=null}BX.removeCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._RestoreScrollTop,this))};i.prototype._IEBodyClearHandler=function(e){var t=this.document.body.firstChild;if(e.keyCode==this.editor.KEY_CODES["enter"]&&t.nodeName=="P"&&t!=this.document.body.lastChild){if(t.innerHTML&&t.innerHTML.toLowerCase()=="<br>"){var i=t.nextSibling;this.editor.util.ReplaceWithOwnChildren(t);t=i}}if(t&&t.nodeName=="P"&&t==this.document.body.lastChild){this.editor.util.ReplaceWithOwnChildren(t)}BX.removeCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._IEBodyClearHandler,this))};i.prototype._IEBodyClearHandlerEx=function(e){var t=this.document.body.firstChild;if(e.keyCode==this.editor.KEY_CODES["backspace"]&&t&&t.nodeName=="P"&&t==this.document.body.lastChild&&(this.editor.util.IsEmptyNode(t,true,true)||t.innerHTML&&t.innerHTML.toLowerCase()=="<br>")){this.editor.util.ReplaceWithOwnChildren(t)}BX.removeCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._IEBodyClearHandlerEx,this))};i.prototype.OnEnterHandler=function(e,t,i,o){if(BX.browser.IsChrome()){this.document.body.style.minHeight=parseInt(this.document.body.style.minHeight)+1+"px";this.document.body.style.minHeight=parseInt(this.document.body.style.minHeight)-1+"px"}if(!i){return}var n=this;function r(e){if(e){if(e.nodeName!=="P"&&e.nodeName!=="DIV"){e=BX.findParent(e,(function(e){return e.nodeName==="P"||e.nodeName==="DIV"}),n.document.body)}var t=n.editor.util.GetInvisibleTextNode();if(e){e.parentNode.insertBefore(t,e);n.editor.util.ReplaceWithOwnChildren(e);n.editor.selection.SelectNode(t)}}}var s,a,l,d=["LI","P","H1","H2","H3","H4","H5","H6"],u=["UL","OL","MENU"];if(BX.util.in_array(i.nodeName,d)){l=i}else{l=BX.findParent(i,(function(e){return BX.util.in_array(e.nodeName,d)}),this.document.body)}if(l){if(l.nodeName==="LI"){if(t===n.editor.KEY_CODES["enter"]&&l&&l.parentNode){var c=n.editor.action.actions.insertUnorderedList.getCustomBullitClass(l.parentNode)}setTimeout((function(){var e=n.editor.selection.GetSelectedNode(true);if(e){s=BX.findParent(e,(function(e){return BX.util.in_array(e.nodeName,u)}),n.document.body);if(t===n.editor.KEY_CODES["enter"]&&l&&l.parentNode){n.editor.action.actions.insertUnorderedList.checkCustomBullitList(l.parentNode,c,true)}if(s&&BX.browser.IsChrome()&&t===n.editor.KEY_CODES["enter"]){var i,o=s.getElementsByTagName("LI");for(i=0;i<o.length;i++){o[i].innerHTML=o[i].innerHTML.replace(/\uFEFF/gi,"")}}if(!s){r(e)}}}),0)}else if(l.nodeName.match(/H[1-6]/)&&t===this.editor.KEY_CODES["enter"]){setTimeout((function(){r(n.editor.selection.GetSelectedNode())}),0)}return true}if(t===this.editor.KEY_CODES["enter"]&&!BX.browser.IsFirefox()&&this.editor.action.IsSupported("insertLineBreak")){if(BX.browser.IsIE10()||BX.browser.IsIE11()){this.editor.action.Exec("insertHTML","<br>"+this.editor.INVISIBLE_SPACE)}else if(BX.browser.IsChrome()){this.editor.action.Exec("insertLineBreak");if(BX.browser.IsMac()){var f="bx-editor-temp-"+Math.round(Math.random()*1e6);this.editor.action.Exec("insertHTML",'<span id="'+f+'">'+this.editor.INVISIBLE_SPACE+"</span>");var h=this.editor.GetIframeElement(f);if(h)BX.remove(h)}else{this.editor.action.Exec("insertHTML",this.editor.INVISIBLE_SPACE)}}else{this.editor.action.Exec("insertLineBreak")}return BX.PreventDefault(e)}if((BX.browser.IsChrome()||BX.browser.IsIE10()||BX.browser.IsIE11())&&t==this.editor.KEY_CODES["backspace"]&&o.collapsed){var m=BX.create("SPAN",false,this.document);this.editor.selection.InsertNode(m);var p=m.previousSibling;if(p&&p.nodeType==3&&this.editor.util.IsEmptyNode(p,false,false)){BX.remove(p)}this.editor.selection.SetBefore(m);BX.remove(m)}};i.prototype.OnEnterHandlerKeyUp=function(e,t,i){if(i){var o=this;if(!BX.util.in_array(i.nodeName,this.editor.GetBlockTags())){i=BX.findParent(i,(function(e){return BX.util.in_array(e.nodeName,o.editor.GetBlockTags())}),this.document.body)}if(i&&BX.util.in_array(i.nodeName,this.editor.GetBlockTags())){var n=BX.util.trim(i.innerHTML).toLowerCase();if(this.editor.util.IsEmptyNode(i,true,true)||n==""||n=="<br>"){i.removeAttribute("class")}}}};i.prototype.OnKeyDownArrowsHandler=function(e,t,i){var o,n,r,s,a=this.editor.KEY_CODES;this.keyDownRange=i;if(t===a["right"]||t===a["down"]){o=i.endContainer;r=o?o.nextSibling:false;n=o?o.parentNode:false;if(o.nodeType==3&&o.length==i.endOffset&&n&&n.nodeName!=="BODY"&&(!r||r&&r.nodeName=="BR"&&!r.nextSibling)&&(this.editor.util.IsBlockElement(n)||this.editor.util.IsBlockNode(n))){this.editor.selection.SetInvisibleTextAfterNode(n,true);return BX.PreventDefault(e)}else if(o.nodeType==3&&this.editor.util.IsEmptyNode(o)&&r&&(this.editor.util.IsBlockElement(r)||this.editor.util.IsBlockNode(r))){BX.remove(o);if(r.firstChild){this.editor.selection.SetBefore(r.firstChild)}else{this.editor.selection.SetAfter(r)}return BX.PreventDefault(e)}else if(o.nodeType==3&&o.length==i.endOffset&&n&&n.nodeName!=="BODY"&&r&&r.nodeName=="BR"&&!r.nextSibling&&(this.editor.util.IsBlockElement(n)||this.editor.util.IsBlockNode(n))){this.editor.selection.SetInvisibleTextAfterNode(n,true);return BX.PreventDefault(e)}}else if(t===a["left"]||t===a["up"]){o=i.startContainer;n=o?o.parentNode:false;s=o?o.previousSibling:false;if(o.nodeType==3&&i.endOffset===0&&n&&n.nodeName!=="BODY"&&!s&&(this.editor.util.IsBlockElement(n)||this.editor.util.IsBlockNode(n))){this.editor.selection.SetInvisibleTextBeforeNode(n);return BX.PreventDefault(e)}else if(o.nodeType==3&&this.editor.util.IsEmptyNode(o)&&s&&(this.editor.util.IsBlockElement(s)||this.editor.util.IsBlockNode(s))){BX.remove(o);if(s.lastChild){this.editor.selection.SetAfter(s.lastChild)}else{this.editor.selection.SetBefore(s)}return BX.PreventDefault(e)}}return true};i.prototype.OnKeyUpArrowsHandler=function(e,t){var i=this,o,n,r,s,a,l=this.editor.selection.GetRange(),d,u,c,f,h,m,p,y,S,v,B,C=this.editor.KEY_CODES;if(t===C["right"]||t===C["down"]){this.editor.selection.GetStructuralTags();if(l.collapsed){d=l.endContainer;h=this.editor.util.IsEmptyNode(d);p=this.editor.selection.CheckLastRange(l);c=d.nextSibling;if(!this.editor.util.CheckPreCursorSupport()){if(d.nodeName==="PRE"){o=d}else if(d.nodeType==3){o=BX.findParent(d,{tag:"PRE"},this.element)}if(o){if(this.keyDownRange){s=this.keyDownRange.endContainer;a=s==o?o:BX.findParent(s,(function(e){return e==o}),this.element)}i.FocusPreElement(o,false,a?null:"start")}}if(d.nodeType==3&&h&&c){d=c;h=this.editor.util.IsEmptyNode(d)}m=this.editor.util.CheckSurrogateNode(d);if(m){r=d.nextSibling;if(r&&r.nodeType==3&&this.editor.util.IsEmptyNode(r))this.editor.selection._MoveCursorAfterNode(r);else this.editor.selection._MoveCursorAfterNode(d);BX.PreventDefault(e)}else if(d.nodeType==1&&d.nodeName!="BODY"&&!h){if(p){this.editor.selection._MoveCursorAfterNode(d);BX.PreventDefault(e)}}else if(p&&d.nodeType==3&&!h){u=d.parentNode;if(u&&d===u.lastChild&&u.nodeName!="BODY"){this.editor.selection._MoveCursorAfterNode(u)}}else if(d.nodeType==3&&d.parentNode){u=d.parentNode;f=u.previousSibling;if((this.editor.util.IsBlockElement(u)||this.editor.util.IsBlockNode(u))&&f&&f.nodeType==3&&this.editor.util.IsEmptyNode(f)){BX.remove(f)}}}else{y=l.startContainer;S=l.endContainer;v=this.editor.util.CheckSurrogateNode(y);B=this.editor.util.CheckSurrogateNode(S);if(v){n=y.previousSibling;if(n&&n.nodeType==3&&this.editor.util.IsEmptyNode(n))l.setStartBefore(n);else l.setStartBefore(y);this.editor.selection.SetSelection(l)}if(B){r=S.nextSibling;if(r&&r.nodeType==3&&this.editor.util.IsEmptyNode(r))l.setEndAfter(r);else l.setEndAfter(S);this.editor.selection.SetSelection(l)}}}else if(t===C["left"]||t===C["up"]){this.editor.selection.GetStructuralTags();if(l.collapsed){d=l.startContainer;h=this.editor.util.IsEmptyNode(d);p=this.editor.selection.CheckLastRange(l);if(d.nodeType==3&&h&&d.previousSibling){d=d.previousSibling;h=this.editor.util.IsEmptyNode(d)}if(!this.editor.util.CheckPreCursorSupport()){if(d.nodeName==="PRE"){o=d}else if(d.nodeType==3){o=BX.findParent(d,{tag:"PRE"},this.element)}if(o){if(this.keyDownRange){s=this.keyDownRange.startContainer;a=s==o?o:BX.findParent(s,(function(e){return e==o}),this.element)}i.FocusPreElement(o,false,a?null:"end")}}m=this.editor.util.CheckSurrogateNode(d);if(m){n=d.previousSibling;if(n&&n.nodeType==3&&this.editor.util.IsEmptyNode(n))this.editor.selection._MoveCursorBeforeNode(n);else this.editor.selection._MoveCursorBeforeNode(d);BX.PreventDefault(e)}else if(d.nodeType==1&&d.nodeName!="BODY"&&!h){if(p){this.editor.selection._MoveCursorBeforeNode(d);BX.PreventDefault(e)}}else if(p&&d.nodeType==3&&!h){u=d.parentNode;if(u&&d===u.firstChild&&u.nodeName!="BODY"){this.editor.selection._MoveCursorBeforeNode(u)}}else if(d.nodeType==3&&d.parentNode){u=d.parentNode;f=u.nextSibling;if((this.editor.util.IsBlockElement(u)||this.editor.util.IsBlockNode(u))&&f&&f.nodeType==3&&this.editor.util.IsEmptyNode(f)){BX.remove(f)}}}else{y=l.startContainer;S=l.endContainer;v=this.editor.util.CheckSurrogateNode(y);B=this.editor.util.CheckSurrogateNode(S);if(v){n=y.previousSibling;if(n&&n.nodeType==3&&this.editor.util.IsEmptyNode(n))l.setStartBefore(n);else l.setStartBefore(y);this.editor.selection.SetSelection(l)}if(B){r=S.nextSibling;if(r&&r.nodeType==3&&this.editor.util.IsEmptyNode(r))l.setEndAfter(r);else l.setEndAfter(S);this.SetSelection(l)}}}this.keyDownRange=null};i.prototype.FocusPreElement=function(e,t,i){var o=this;if(this._focusPreElementTimeout)this._focusPreElementTimeout=clearTimeout(this._focusPreElementTimeout);if(t){this._focusPreElementTimeout=setTimeout((function(){o.FocusPreElement(e,false,i)}),100);return}BX.focus(e);if(i=="end"&&e.lastChild){this.editor.selection.SetAfter(e.lastChild)}else if(i=="start"&&e.firstChild){this.editor.selection.SetBefore(e.firstChild)}};i.prototype.OnPasteHandler=function(e){if(!this.editor.skipPasteHandler){this.editor.skipPasteHandler=true;this.editor.pasteNodeIndex={};var t=document.documentElement.scrollTop||document.body.scrollTop,i=document.documentElement.scrollLeft||document.body.scrollLeft,o=this,n=[],r,s,a,l;function d(e){if(e&&e.setAttribute){var t=Math.round(Math.random()*1e6);o.editor.pasteNodeIndex[t]=true;e.setAttribute("data-bx-paste-flag",t)}}r=this.document.body;if(r){l=r.querySelectorAll("*");for(s=0;s<l.length;s++){if(l[s].nodeType==1&&l[s].nodeName!="BODY"&&l[s].nodeName!="HEAD"){n.push(l[s])}}for(s=0;s<r.parentNode.childNodes.length;s++){a=r.parentNode.childNodes[s];if(a.nodeType==1&&a.nodeName!="BODY"&&a.nodeName!="HEAD"){n.push(a)}}}for(s=0;s<n.length;s++){d(n[s])}var u=this.editor.synchro.IsSyncOn();if(u){this.editor.synchro.StopSync()}if(this.editor.iframeView.pasteHandlerTimeout){clearTimeout(this.editor.iframeView.pasteHandlerTimeout)}this.pasteHandlerTimeout=setTimeout((function(){o.editor.SetCursorNode();o.editor.pasteHandleMode=true;o.editor.bbParseContentMode=true;o.editor.synchro.lastIframeValue=false;if(!o.editor.skipPasteControl){o.editor.pasteControl.SaveIframeContent(o.GetValue());o.editor.pasteControl.CheckAndShow()}o.editor.synchro.FromIframeToTextarea(true,true);o.editor.pasteHandleMode=false;o.editor.bbParseContentMode=false;o.editor.synchro.lastTextareaValue=false;o.editor.synchro.FromTextareaToIframe(true);o.editor.RestoreCursor();o.editor.On("OnIframePaste");o.editor.On("OnIframeNewWord");o.editor.skipPasteHandler=false;if(u){o.editor.synchro.StartSync()}if(window.scrollTo){window.scrollTo(i,t)}}),0)}};i.prototype.InitAutoLinking=function(){var e=this,t=this.editor,i=t.action.IsSupportedByBrowser("autoUrlDetect"),o=BX.browser.IsIE()||BX.browser.IsIE9()||BX.browser.IsIE10();if(i)t.action.Exec("autoUrlDetect",false);if(t.config.autoLink===false)return;var n={CODE:1,PRE:1,A:1,SCRIPT:1,HEAD:1,TITLE:1,STYLE:1},r=/(((?:https?|ftp):\/\/|www\.)[^\s'"<]{3,500})/gi,s=/[\.a-z0-9_\-]+@[\.a-z0-9_\-]+\.[\.a-z0-9_\-]+/gi,a=100,l={")":"(","]":"[","}":"{"};this.editor.autolinkUrlRegExp=r;this.editor.autolinkEmailRegExp=s;function d(){try{if(u()){t.selection.ExecuteAndRestore((function(e,t){if(t&&t.parentNode)c(t.parentNode)}))}}catch(e){}}function u(){var e,i,o=false,n=t.GetIframeDoc(),a=n.createTreeWalker(n.body,NodeFilter.SHOW_TEXT,null,false);while(e=a.nextNode()){i=e.nodeValue||"";if((i.match(s)||i.match(r))&&e.parentNode&&e.parentNode.nodeName!="A"){o=true;break}}return o}function c(e){if(e&&!n[e.nodeName]){var t=BX.findParent(e,(function(e){return!!n[e.nodeName]}),e.ownerDocument.body);if(t)return e;if(e===e.ownerDocument.documentElement)e=e.ownerDocument.body;return p(e)}}function f(t){t=BX.util.htmlspecialchars(t);return t.replace(r,(function(t,i){var o=(i.match(/([^\w\u0430-\u0456\u0451\/\-#](,?))$/i)||[])[1]||"",n=l[o];i=i.replace(/([^\w\u0430-\u0456\u0451\/\-#](,?))$/i,"");if(i.split(n).length>i.split(o).length){i=i+o;o=""}var r=i,s=BX.util.htmlspecialchars(i);if(i.length>a)s=s.substr(0,a)+"...";if(r.substr(0,4)==="www.")r="http://"+r;BX.onCustomEvent(e.editor,"OnAfterUrlConvert",[r]);return'<a href="'+r+'">'+s+"</a>"+o}))}function h(e){e=BX.util.htmlspecialchars(e);return e.replace(s,(function(e){var t=(e.match(/([^\w\/\-](,?))$/i)||[])[1]||"",i=l[t];e=e.replace(/([^\w\/\-](,?))$/i,"");if(e.split(i).length>e.split(t).length){e=e+t;t=""}var o="mailto:"+e;return'<a href="'+o+'">'+e+"</a>"+t}))}function m(e){var t=e._bx_autolink_temp_div;if(!t)t=e._bx_autolink_temp_div=e.createElement("div");return t}function p(e){var t,i,o;if(e&&!n[e.nodeName]){if(e.nodeType===3&&e.data.match(r)&&e.parentNode){i=e.parentNode;o=m(i.ownerDocument);o.innerHTML="<span></span>"+f(e.data);o.removeChild(o.firstChild);while(o.firstChild)i.insertBefore(o.firstChild,e);i.removeChild(e)}else if(e.nodeType===3&&e.data.match(s)&&e.parentNode){i=e.parentNode;o=m(i.ownerDocument);o.innerHTML="<span></span>"+h(e.data);o.removeChild(o.firstChild);while(o.firstChild)i.insertBefore(o.firstChild,e);i.removeChild(e)}else if(e.nodeType===1){var a=e.childNodes,l;for(l=0;l<a.length;l++)p(a[l]);t=e}}return t}if(!o||o&&i){BX.addCustomEvent(t,"OnIframeNewWord",(function(){if(t.autolinkTimeout)t.autolinkTimeout=clearTimeout(t.autolinkTimeout);t.autolinkTimeout=setTimeout(d,500)}));BX.addCustomEvent(t,"OnSubmit",(function(){try{c(t.GetIframeDoc().body)}catch(e){}}))}var y=t.sandbox.GetDocument().getElementsByTagName("a"),S=function(e){var i=BX.util.trim(t.util.GetTextContent(e));if(i.substr(0,4)==="www.")i="http://"+i;return i};BX.addCustomEvent(t,"OnIframeKeydown",(function(e,t,i,o){if(y.length>0&&o){var n=BX.findParent(o,{tag:"A"},o.ownerDocument.body);if(n){var s=S(n);setTimeout((function(){var e=S(n);if(e===s)return;if(e.match(r))n.setAttribute("href",e)}),0)}}}))};i.prototype.IsUserTypingNow=function(e){return this.isFocused&&this.isShown&&this.isUserTyping};i.prototype.CheckContentLastChild=function(e){if(!e){e=this.element}var t=e.lastChild;if(t&&(this.editor.util.IsEmptyNode(t,true)&&this.editor.util.IsBlockNode(t.previousSibling)||this.editor.phpParser.IsSurrogate(t))){e.appendChild(BX.create("BR",{},e.ownerDocument));e.appendChild(this.editor.util.GetInvisibleTextNode())}};function n(e,t,i){this.INTERVAL=500;this.editor=e;this.textareaView=t;this.iframeView=i;this.lastFocused="wysiwyg";this.InitEventHandlers()}n.prototype={FromIframeToTextarea:function(e,t){var i;if(this.editor.bbCode){i=this.iframeView.GetValue(this.editor.bbParseContentMode,false);i=BX.util.trim(i);if(i!==this.lastIframeValue){var o=this.editor.bbParser.Unparse(i);this.textareaView.SetValue(o,false,t||this.editor.bbParseContentMode);if(typeof this.lastSavedIframeValue!=="undefined"&&this.lastSavedIframeValue!=i){this.editor.On("OnContentChanged",[o,i])}this.lastSavedIframeValue=i;this.lastIframeValue=i}}else{i=this.iframeView.GetValue();i=BX.util.trim(i);if(i!==this.lastIframeValue){this.textareaView.SetValue(i,true,t);if(typeof this.lastSavedIframeValue!=="undefined"&&this.lastSavedIframeValue!=i){this.editor.On("OnContentChanged",[this.textareaView.GetValue()||"",i||""])}this.lastSavedIframeValue=i;this.lastIframeValue=i}}},FromTextareaToIframe:function(e){var t=this.textareaView.GetValue();if(t!==this.lastTextareaValue){if(t){if(this.editor.bbCode){var i=this.editor.bbParser.Parse(t);i=i.replace(/\u2060/gi,'<span id="bx-cursor-node"> </span>');this.iframeView.SetValue(i,e)}else{t=t.replace(/\u2060/gi,'<span id="bx-cursor-node"> </span>');this.iframeView.SetValue(t,e)}}else{this.iframeView.Clear()}this.lastTextareaValue=t;this.editor.On("OnContentChanged",[t||"",this.iframeView.GetValue()||""])}},FullSyncFromIframe:function(){this.lastIframeValue=false;this.FromIframeToTextarea(true,true);this.lastTextareaValue=false;this.FromTextareaToIframe(true)},Sync:function(){var e=true;var t=this.editor.currentViewName;if(t==="split"){if(this.GetSplitMode()==="code"){this.FromTextareaToIframe(e)}else{this.FromIframeToTextarea(e)}}else if(t==="code"){this.FromTextareaToIframe(e)}else{this.FromIframeToTextarea(e)}},GetSplitMode:function(){var e=false;if(this.editor.currentViewName=="split"){if(this.editor.iframeView.IsFocused()){e="wysiwyg"}else if(this.editor.textareaView.IsFocused()){e="code"}else{e=this.lastFocused}}return e},InitEventHandlers:function(){var e=this;BX.addCustomEvent(this.editor,"OnTextareaFocus",(function(){e.lastFocused="code";e.StartSync()}));BX.addCustomEvent(this.editor,"OnIframeFocus",(function(){e.lastFocused="wysiwyg";e.StartSync()}));BX.addCustomEvent(this.editor,"OnTextareaBlur",BX.delegate(this.StopSync,this));BX.addCustomEvent(this.editor,"OnIframeBlur",BX.delegate(this.StopSync,this))},StartSync:function(e){var t=this;if(this.interval){this.interval=clearTimeout(this.interval)}this.delay=e||this.INTERVAL;function i(){t.delay=t.INTERVAL;t.Sync();t.interval=setTimeout(i,t.delay)}this.interval=setTimeout(i,t.delay)},StopSync:function(){if(this.interval){this.interval=clearTimeout(this.interval)}},IsSyncOn:function(){return!!this.interval},OnIframeMousedown:function(e,t,i){},IsFocusedOnTextarea:function(){return this.editor.currentViewName==="code"||this.editor.currentViewName==="split"&&this.GetSplitMode()==="code"}};window.BXEditorTextareaView=t;window.BXEditorIframeView=i;window.BXEditorViewsSynchro=n})();
//# sourceMappingURL=html-views.map.js